package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Alltext;
import com.ruoyi.system.service.IAlltextService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 所有文本Controller
 *
 * @author ruoyi
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/system/alltext")
public class AlltextController extends BaseController
{
    @Autowired
    private IAlltextService alltextService;

    /**
     * 查询所有文本列表
     */
    @PreAuthorize("@ss.hasPermi('system:alltext:list')")
    @GetMapping("/list")
    public TableDataInfo list(Alltext alltext)
    {
        startPage();
        List<Alltext> list = alltextService.selectAlltextList(alltext);
        return getDataTable(list);
    }

    /**
     * 导出所有文本列表
     */
    @PreAuthorize("@ss.hasPermi('system:alltext:export')")
    @Log(title = "所有文本", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Alltext alltext)
    {
        List<Alltext> list = alltextService.selectAlltextList(alltext);
        ExcelUtil<Alltext> util = new ExcelUtil<Alltext>(Alltext.class);
        util.exportExcel(response, list, "所有文本数据");
    }

    /**
     * 获取所有文本详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:alltext:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(alltextService.selectAlltextById(id));
    }

    /**
     * 新增所有文本
     */
    @PreAuthorize("@ss.hasPermi('system:alltext:add')")
    @Log(title = "所有文本", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Alltext alltext)
    {
        return toAjax(alltextService.insertAlltext(alltext));
    }

    /**
     * 修改所有文本
     */
    @PreAuthorize("@ss.hasPermi('system:alltext:edit')")
    @Log(title = "所有文本", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Alltext alltext)
    {
        return toAjax(alltextService.updateAlltext(alltext));
    }

    /**
     * 删除所有文本
     */
    @PreAuthorize("@ss.hasPermi('system:alltext:remove')")
    @Log(title = "所有文本", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(alltextService.deleteAlltextByIds(ids));
    }
}
